import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:largefriends/pages/lf_suspend/lf_suspend_logic.dart';
import 'package:largefriends/res/lf_color.dart';
import 'package:largefriends/res/lf_double_ext.dart';

import '../../config/lf_config.dart';
import '../../res/lf_fonts.dart';
import '../../res/lf_text_style.dart';
import '../../res/strings/lf_strings.dart';
import '../../widgets/lf_app_bar.dart';
import '../lf_browser/lf_browser_logic.dart';
import '../lf_feedback/lf_feedback_logic.dart';

class LfSuspendPage extends StatefulWidget {
  const LfSuspendPage({super.key});

  @override
  State<LfSuspendPage> createState() => _LfSuspendPageState();
}

class _LfSuspendPageState extends State<LfSuspendPage> {
  final logic = Get.put(LfSuspendLogic());

  @override
  Widget build(BuildContext context) {
    return WillPopScope(
        child: Scaffold(
          appBar: lfAppBar(
              title: strSuspend.tr,
              centerTitle: true,
              leadingCallback: logic.authService.loggedIn()
                  ? null
                  : () {
                      logic.logout();
                    }),
          body: Padding(
              padding: EdgeInsets.symmetric(horizontal: 15.w),
              child: CustomScrollView(slivers: [
                20.h.sliverBox,
                Text.rich(
                  TextSpan(children: [
                    TextSpan(
                      text: strSuspendContent.tr.split("%%s").first,
                    ),
                    TextSpan(
                        text: strServiceAgreement.tr,
                        style: lfTextStyle(
                            sp: 17.sp,
                            fontFamily: fontBold,
                            decoration: TextDecoration.underline),
                        recognizer: TapGestureRecognizer()
                          ..onTap = () {
                            toBrowserPage(
                                title: strServiceAgreement.tr.toUpperCase(),
                                url: '$webUrl$serviceAgreementUrl');
                          }),
                    TextSpan(
                      text: strSuspendContent.tr.split("%%s").last,
                    ),
                  ]),
                  style: lfTextStyle(sp: 17.sp, fontFamily: fontMedium),
                  textAlign: TextAlign.left,
                ).sliverBox,
                40.h.sliverBox,
                Row(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Container(
                      margin: EdgeInsets.only(top: 2.h),
                      width: 8.r,
                      height: 14.h,
                      decoration: BoxDecoration(
                          color: colorFEFEFE, borderRadius: 10.r.radius),
                    ),
                    8.w.sbw,
                    Expanded(
                      child: Text(
                        strSuspendTip1.tr,
                        style: lfTextStyle(sp: 17.sp, fontFamily: fontRegular),
                      ),
                    ),
                  ],
                ).sliverBox,
                10.h.sliverBox,
                Row(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Container(
                      margin: EdgeInsets.only(top: 2.h),
                      width: 8.r,
                      height: 14.h,
                      decoration: BoxDecoration(
                          color: colorFEFEFE, borderRadius: 10.r.radius),
                    ),
                    8.w.sbw,
                    Expanded(
                        child: Text(
                      strSuspendTip2.tr,
                      style: lfTextStyle(sp: 17.sp, fontFamily: fontRegular),
                    )),
                  ],
                ).sliverBox,
                10.h.sliverBox,
                Row(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Container(
                      margin: EdgeInsets.only(top: 2.h),
                      width: 8.r,
                      height: 14.h,
                      decoration: BoxDecoration(
                          color: colorFEFEFE, borderRadius: 10.r.radius),
                    ),
                    8.w.sbw,
                    Expanded(
                        child: Text(
                      strSuspendTip3.tr,
                      style: lfTextStyle(sp: 17.sp, fontFamily: fontRegular),
                    )),
                  ],
                ).sliverBox,
                10.h.sliverBox,
                Row(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Container(
                      margin: EdgeInsets.only(top: 2.h),
                      width: 8.r,
                      height: 14.h,
                      decoration: BoxDecoration(
                          color: colorFEFEFE, borderRadius: 10.r.radius),
                    ),
                    8.w.sbw,
                    Expanded(
                        child: Text(
                      strSuspendTip4.tr,
                      style: lfTextStyle(sp: 17.sp, fontFamily: fontRegular),
                    )),
                  ],
                ).sliverBox,
                40.h.sliverBox,
                Text.rich(
                  TextSpan(children: [
                    TextSpan(
                      text: strSuspendTip5.tr.split("%%s").first,
                    ),
                    TextSpan(
                        text: strContactUs.tr,
                        style: lfTextStyle(
                            sp: 17.sp,
                            fontFamily: fontBold,
                            decoration: TextDecoration.underline),
                        recognizer: TapGestureRecognizer()
                          ..onTap = () {
                            toFeedback(type: FeedbackType.account);
                          }),
                    TextSpan(
                      text: strSuspendTip5.tr.split("%%s").last,
                    ),
                  ]),
                  style: lfTextStyle(sp: 17.sp, fontFamily: fontRegular),
                  textAlign: TextAlign.left,
                ).sliverBox,
                20.h.sliverBox,
                logic.authService.loggedIn()
                    ? InkWell(
                        child: Padding(
                          padding: EdgeInsets.only(right: 16.w),
                          child: Center(
                            child: Text(
                              strLogout.tr,
                              style: lfTextStyle(
                                  sp: 20.sp,
                                  fontFamily: fontBold,
                                  color: colorFEFEFE,
                                  decoration: TextDecoration.underline),
                            ),
                          ),
                        ),
                        onTap: () {
                          logic.logout();
                        },
                      ).sliverBox
                    : 20.h.sliverBox,
              ])),
        ),
        onWillPop: () async {
          logic.logout();
          return false;
        });
  }
}
